package com.chuzhiyun.chengguoxy.feature.login;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.View;

import com.chuzhiyun.chengguoxy.R;
import com.chuzhiyun.chengguoxy.databinding.ActivityPnlessBinding;
import com.chuzhiyun.chengguoxy.feature.base.BaseActivity;
import com.chuzhiyun.chengguoxy.feature.home.HomeActivity;
import com.chuzhiyun.chengguoxy.utlis.CustomClickListener;

public class PnlessActivity extends BaseActivity<ActivityPnlessBinding> {

    private String mPhoneNumber;
    private String wxCode;
    @Override
    public void initView(View view) {
        viewBinding.submitText.setEnabled(false);
        viewBinding.editPhone.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {

            }

            @Override
            public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
                if (viewBinding.editPhone.getText().length()==11){
                    viewBinding.submitText.setBackgroundResource(R.drawable.login_btn);
                    viewBinding.submitText.setEnabled(true);
                    mPhoneNumber = viewBinding.editPhone.getText()+"";
                }else {
                    viewBinding.submitText.setBackgroundResource(R.drawable.login_btnnor);
                    viewBinding.submitText.setEnabled(false);
                }
            }

            @Override
            public void afterTextChanged(Editable editable) {

            }
        });
        viewBinding.submitText.setOnClickListener(new CustomClickListener() {
            @Override
            protected void onSingleClick() {
                Intent intent = new Intent();
                intent.setClass(mContext,PnlessCodeActivity.class);
                intent.putExtra("mPhoneNumber",mPhoneNumber);
                intent.putExtra("wxCode",wxCode);
                startActivity(intent);
            }
        });
    }

    @Override
    public void initData() {

    }

    @Override
    public void setListener() {
        wxCode = getIntent().getStringExtra("wxCode");
    }
    
    @Override
    protected ActivityPnlessBinding getViewBinding() {
        return ActivityPnlessBinding.inflate(getLayoutInflater(), baseBinding.getRoot(), true);
    }
}